package com.cuanbo.dualscreenteachzhu.utils;

import androidx.annotation.NonNull;

import com.cuanbo.dualscreenteachzhu.base.App;

/**
 *未捕获异常处理
 */
public class LogUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {

    @Override
    public void uncaughtException(@NonNull Thread t, @NonNull Throwable e) {
        LogUtil.addError("------------------------------未捕获的异常--------------------------------");
        LogUtil.addError("ThreadName="+t.getName());
        LogUtil.addError("ErrorMessage="+e.getMessage());
        LogUtil.addError(t, e);
        LogUtil.addError("-------------------------------------------------------------------------");
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException interruptedException) {}
                App.getInstance().exitApp();
                App.getInstance().restartApp();
            }
        }).start();
    }

}
